from django.shortcuts import render

# Create your views here.
from rest_framework.views import APIView
from rest_framework.response import Response
from .ser import *
class JournalismAPIView(APIView):
    def get(self,request):
        data = Journalism.objects.all()
        ser = JournalismSer(data,many=True)
        return Response(ser.data)
    def post(self,request):
        data = request.data
        ser = JournalismSer(data=data)
        ser.is_valid(raise_exception=True)
        ser.save()
        return Response(ser.data)

class AdvertisingAPIView(APIView):
    def get(self, request):
        data = Advertising.objects.all()
        ser = AdvertisingASer(data, many=True)
        return Response(ser.data)
    def post(self, request):
        data = request.data
        ser = AdvertisingASer(data=data)
        ser.is_valid(raise_exception=True)
        ser.save()
        return Response(ser.data)
